# Optional vars
# - checkcompose_server
##      string - hostname of openQA server to connect to (if not set, openQA
##               client configuration will determine this, default will be
##               localhost)
# - checkcompose_url
##      string - base URL for openQA result links (if not set, will be
##               the URL the client actually wound up connecting to)
# - checkcompose_wait
##      string - (digits) time in minutes to wait for openQA tests to complete
##               before sending the report (defaults to 480)
# - checkcompose_emailfrom
##      string - Email address to send report from (if not set, no report sent)
# - checkcompose_emailto
##      string - Email address to send report to (if not set but email-from
##               set, report will go to email-from, for testing usually)
##               Split multiple addresses with spaces
# - checkcompose_smtp
##      string - SMTP server to use for sending the report
# - checkcompose_json
##      string - File to append JSON-formatted report summary to
# - checkcompose_loglevel
##      string - log level
#
# NOTE: this is missing /etc/openqa/client.conf configuration, for now;
# we're assuming it'll be deployed on the openqa server boxes and hence
# client.conf will be in place (and localhost default would be correct
# anyhow)

#- name: Install required packages (testing)
#  dnf: name={{ item }} state=present enablerepo="updates-testing"
#  with_items:
#  - python2-fedfind
#  tags:
#  - packages

- name: Install required packages
  dnf: name={{ item }} state=present
  with_items:
  - python2-fedfind
  - python2-fedmsg-consumers
  - python2-openqa_client
  - python-setuptools
  - python-six
  tags:
  - packages

- name: Check out check-compose
  git:
    repo: https://pagure.io/fedora-qa/check-compose.git
    dest: /root/check-compose
  register: gitcc

- name: Install check-compose
  command: "python setup.py install"
  args:
    chdir: /root/check-compose
  when: "gitcc|changed"
  notify:
  - restart fedmsg-hub

- name: Enable fedmsg consumer
  template: src=checkcomp_consumer.py.j2 dest=/etc/fedmsg.d/checkcomp_consumer.py owner=root group=root mode=0644
  notify:
  - restart fedmsg-hub
  tags:
  - config

- name: Install config file
  template: src=check-compose.conf.j2 dest=/etc/check-compose.conf mode=0644
  tags:
  - config
